package com.xgp.laboratorymanagementsystem.service.impl;

import com.xgp.laboratorymanagementsystem.mapper.UserMapper;
import com.xgp.laboratorymanagementsystem.model.User;
import com.xgp.laboratorymanagementsystem.model.UserExample;
import com.xgp.laboratorymanagementsystem.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User fingLoginUser(String username, String password) {
        UserExample userExample = new UserExample();
        userExample.createCriteria().andUsernameEqualTo(Integer.valueOf(username)).andPasswordEqualTo(password);
        List<User> users = userMapper.selectByExample(userExample);
        if(users.size() == 1) {
            return users.get(0);
        }else {
            return null;
        }
    }
}
